Python3交叉编译至arm | 您所在的位置:网站首页 › configure 交叉编译 › Python3交叉编译至arm |
0. 前言
由于需要在arm-linux开发板上运行Python代码,但是里面的Linux系统是裁剪过的,没有包管理工具,所以就下载源码安装 1. 下载Python源代码到 https://www.python.org/ftp/python/ 上下载与电脑对应版本的Python。跟编译用的电脑上一致,因为编译过程中需要调用到电脑上的Python程序,版本不一致容易出现各种语法的错误。 编译中会用到电脑上面的python命令,所以要先将Python3链接到python,否则会出现没有python这个编译器,如下 checking for python3.9... no checking for python3... python3 checking for python interpreter for cross build... configure: error: python3.9 interpreter not found 2. 编译执行下列命令编译安装 --prefix设置安装的位置,便于管理 export CC= {arm-gcc的路径} export CXX= {arm-g++的路径} ./configure --host=arm-linux --build=arm-linux-gnueabihf ac_cv_file__dev_ptmx=no ac_cv_file__dev_ptc=no --disable-ipv6 --prefix=/home/apps/python3 2.1. 编译中遇到的错误 遇到错误configure: error: readelf for the host is required for cross builds 看样子是缺少readelf这个文件 在arm-gcc的bin目录下发现一个arm-linux-gnueabihf-readelf,在此目录执行 ln -s arm-linux-gnueabihf-readelf arm-linux-readelf遇到错误Fatal: You must get working getaddrinfo() function. or you can specify "--disable-ipv6". 因为用不到IPv6,所以在configure后面加上--disable-ipv6 configure: error: set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling 在configure后面加上ac_cv_file__dev_ptmx=no即可 configure: error: set ac_cv_file__dev_ptc to yes/no in your CONFIG_SITE file when cross compiling 同样加上ac_cv_file__dev_ptc=no configure: error: cannot run C compiled programs. If you meant to cross compile, use '--host'. 交叉编译需要设置--host、--build两个参数 3. 安装由于安装过程中并不会将pip和setuptool放到--prefix指定的路径中,而是$HOME/.local下面,所以$HOME/.local下面的bin和lib文件夹先移动到别的地方 执行make install把编译后的Python放到/home/apps/python3中 复制/home/apps/python3和$HOME/.local/bin、$HOME/.local/lib到arm板子上面即可使用。 |
CopyRight 2018-2019 实验室设备网 版权所有 |